package org.example.stream;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Stream08 {
    public static void main(String[] args) {
        Stream<String> nameList = Stream.of(
                "独孤求败", "令狐冲", "风清扬", "东方不败",
                "方证", "任我行", "冲虚", "向问天", "不戒", "不戒");
//        System.out.println(nameList.collect(Collectors.toList()));
//        System.out.println(nameList.collect(Collectors.toSet()));
//        System.out.println(nameList.collect(Collectors.toMap(x->x,x->1,(oldValue,newValue)->newValue)));
//        System.out.println(nameList.collect(Collectors.groupingBy(String::length, Collectors.toList())));
        Map<Integer, String> map = nameList.collect(Collectors.groupingBy(String::length, Collectors.joining("-")));
        for (Map.Entry<Integer, String> entry : map.entrySet()) {
            System.out.println(entry);
        }
    }
}
